<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    function foo(){
        console.log(this.bar);      
    }
    var bar = "global";
    var obj1 = {
        bar: "obj1",
        foo: foo
    };
    var obj2 = {
        bar:"obj2"
    };
    foo();                 // 输出 global         
    obj1.foo();            // 输出 obj1         
    foo.call(obj2);        // 输出 obj2
    new foo();             // 输出 ubdefined
</script>
</html>